package com.isoftstone.app.controller.message;


import com.isoftstone.bank.controller.base.BaseController;
import com.isoftstone.common.Tidings;
import com.isoftstone.util.BocHttpUtil;
import com.isoftstone.util.Const;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
public class MoblieMessage extends BaseController {


    /**
     * 发送短信接口
     *
     * @param request
     */

    @RequestMapping(value = "/app/admin/getmessage", method = RequestMethod.POST)
    @ResponseBody
    public Object getMobleMessage(HttpServletRequest request) {

        Tidings<String>  tidings = new Tidings<>();


        /**
         * 查询个人信息
         */

       try {

           if( this.getSession().getAttribute(Const.MOBLENO) == null ){
               Map<String, String> userMap = BocHttpUtil.queryUserInfo(request);
               this.getSession().setAttribute(Const.MOBLENO, userMap.get("mobileno"));
           }

           BocHttpUtil.getCode(request);


           tidings.setStatus(Const.SUCCESS);


       } catch (Exception ex){

           tidings.setStatus(Const.ERROR);


       }

       return tidings;

    }


    /**
     * 效验短信接口
     * 前端 参数 code
     * @param request
     */
    @RequestMapping(value = "/app/admin/validatemessage", method = RequestMethod.POST)
    @ResponseBody
    public Object validatemessage(HttpServletRequest request) {

        Tidings<String> tidings = new Tidings<String>();

        String verifyStr = BocHttpUtil.verifyCode(request);


        tidings.setT(verifyStr);

        return tidings;


    }


}
